package com.liumuxian.video.web.controller;

import com.liumuxian.video.pojo.Advertising;
import com.liumuxian.video.service.AdvertisingService;
import entity.Result;
import entity.StatusCode;
import org.apache.tools.ant.taskdefs.Get;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ad")
public class AdvertisingController {
    @Autowired
    private AdvertisingService advertisingService;
    @PostMapping("/save")
    public Result save(@RequestBody Advertising advertising){
        advertisingService.save(advertising);
        return new Result(true, StatusCode.OK,"保存成功！");
    }
    @PostMapping("/update")
    public Result update(@RequestBody Advertising advertising){
        advertisingService.update(advertising);
        return new Result(true, StatusCode.OK,"修改成功！");
    }
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable String id){
        advertisingService.delete(id);
        return new Result(true, StatusCode.OK,"删除成功！");
    }
    @GetMapping("/list")
    public Result findAllGesTate(){
        List<Advertising> advertisingList = advertisingService.findAllGesTate(null,null,0);
        return new Result(true, StatusCode.OK,"查询成功！",advertisingList);
    }
    @GetMapping("/{id}")
    public Result findById(@PathVariable String id){
        Advertising advertisingList = advertisingService.findById(id);
        return new Result(true, StatusCode.OK,"查询成功！",advertisingList);
    }


}
